#ifndef LIBRARY_RENTRYWRITER_H
#define LIBRARY_RENTRYWRITER_H

#include "rentry.h"

namespace Library
{

/**
 * A concrete class which provides read-write management of in-memory and
 * on-disk resources (via ResourceFile).
 */
class ResourceEntryWriter : public ResourceEntry
{
	public:
						ResourceEntryWriter();
						ResourceEntryWriter(const String & name, uint32 size,
							void * data);
		virtual			~ResourceEntryWriter();

		// ResourceEntry overrides.
		virtual	void *	acquire();
		virtual	bool8	release();

		// ResourceEntryWriter originals.
		virtual	bool8	name(const String & name);
		virtual	bool8	persistent();
		virtual	void	persistent(bool8 persistent);
		virtual	bool8	save(uint8 format);
		virtual	bool8	saveData(pStream os, bool8 compression);

		virtual String	tocDetails();

		// ResourceEntryWriter class methods.
		static String	tocHeader();

	protected:
		bool8			m_persistent;

		uint32			m_osizecompressed;
		pStream			m_ostream;
		uint32			m_ooffset;

	// prohibited
	private:
		ResourceEntryWriter(ResourceEntry &);
		ResourceEntryWriter & operator=(ResourceEntry &);
};


//----------------------------------------------------------------------------
// Inline
//

/**
 * @return		@b true if persistent, @b false if not persistent.
 *
 * Gets the persistence state of the resource entry.
 */
inline bool8
ResourceEntryWriter::persistent()
{
	return m_persistent;
}

/**
 * @param persistent	Boolean indicating if resource entry is persistent or
 *						not.
 *
 * Sets the persistent state of the resource entry.  @e true indicates the
 * resource entry is persistent and that the resource should not be unloaded
 * from memory even if the use count drops to zero.  @false indicates no
 * persistence allowing the resource to be unloaded from memory when the use
 * count drops to zero.
 */
inline void
ResourceEntryWriter::persistent(bool8 persistent)
{
	m_persistent = persistent;
}

}; // namespace Library

#endif
